import request from '@/utils/base/request';
import { transformParams, AntiGravity } from '@/utils/base/utils';

export async function getTokenByUId(params) {
  return request({
    url: `/api/auth/getTokenByUId?${transformParams(params)}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

/** 获取验证码 */
export async function getCode(params) {
  return request({
    url: `/api/code?${transformParams(params)}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

/** 登录 */
export async function sysLogin(params) {
  return request({
    url: '/api/auth/login',
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

/** ISC登录 */
export async function sysTicketLogin(params) {
  return request('/api/auth/ticketLogin', {
    method: 'POST',
    data: JSON.stringify(params),
  });
}

/** 获取用户信息 */
export async function getUserInfo(params) {
  return request({
    url: `/api/system/user/getInfo?${transformParams(params)}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

/** 获取用户权限菜单 */
export async function getGovRouters(params) {
  return request({
    url: `/api/system/menu/getGovRouters?${transformParams(params)}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

/** 获取⽤户个⼈中⼼信息 */
// export async function getUserInfo(params) {
//   return request(`/system/user/profile?${transformParams(params)}`);
// }

/** 修改个⼈密码 */
export async function updatePwd(params) {
  return request('/api/system/user/profile/updatePwd', {
    method: 'put',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

/** 退出登录 */
export async function loginOut(params) {
  return request('/api/auth/logout', {
    method: 'post',
    body: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}
